﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>截断小数点位数</title>
    <script type="text/javascript" language="JavaScript">
        function sts(){
            var txt = eval(document.getElementById("Text1").value); // 获取要截取的数据
            alert(txt.toFixed(2));  // 显示截取后的数据
        }
    </script>
</head>
<body>
<input id="Text1" type="text"  value="12345.267514" />
<input id="Button1" type="button" value="截取2位" onclick="sts()" />
</body>
</html>